package cn.bdqn.controller;

import cn.bdqn.entity.Actor;
import cn.bdqn.service.ActorService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import javax.annotation.Resource;

@RestController
@RequestMapping("actor")
public class ActorController {
    @Resource
    private ActorService actorService;
    
    @GetMapping
    public ResponseEntity<List<Actor>> queryAll() {
        List<Actor> actors = this.actorService.queryAll();
        return ResponseEntity.ok(actors);
    }

    @GetMapping("{id}")
    public ResponseEntity<Actor> queryById(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(this.actorService.queryById(id));
    }

    @PostMapping
    public ResponseEntity<Actor> add(Actor actor) {
        return ResponseEntity.ok(this.actorService.insert(actor));
    }

    @PutMapping
    public ResponseEntity<Actor> edit(Actor actor) {
        return ResponseEntity.ok(this.actorService.update(actor));
    }
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(Integer id) {
        return ResponseEntity.ok(this.actorService.deleteById(id));
    }

}

